#include<bits/stdc++.h>
using namespace std;
long long n,l,r,k;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	for(k=n-1;k>=0;--k)
	{
		int m=n,i=0;
		while(k+m*i<=r)
		{
			if(k+m*i>=l)
			{
				cout<<k;
				return 0;
			}
			else i++;
		}
	}
}
